package com.bjbn.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bjbn.entity.Organize;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


@Mapper
public interface OrganizeMapper extends BaseMapper<Organize> {

    @Insert("INSERT INTO base_organize(f_id, f_parent_id, f_category, f_en_code, f_full_name,  f_organize_id_tree,  f_enabled_mark, f_sort_code, f_creator_time, f_creator_user_id, f_last_modify_time, f_last_modify_user_id, f_tenant_id) " +
            "VALUES(#{organize.id}, #{organize.parentId}, #{organize.category}, #{organize.enCode}, #{organize.fullName}, #{organize.organizeIdTree},#{organize.enabledMark},#{organize.sortCode},#{organize.creatorTime},#{organize.creatorUserId},#{organize.lastModifyTime},#{organize.lastModifyUserId},#{organize.tenantId}) " +
            "ON CONFLICT (f_id,f_tenant_id) DO UPDATE SET " +
            "f_parent_id = EXCLUDED.f_parent_id, " +
            "f_category = EXCLUDED.f_category," +
            "f_en_code = EXCLUDED.f_en_code , " +
            "f_full_name = EXCLUDED.f_full_name, " +
            "f_organize_id_tree = EXCLUDED.f_organize_id_tree," +
            "f_enabled_mark = EXCLUDED.f_enabled_mark," +
            "f_sort_code = EXCLUDED.f_sort_code," +
            "f_last_modify_time = EXCLUDED.f_last_modify_time, " +
            "f_last_modify_user_id = EXCLUDED.f_last_modify_user_id")
    int insertOrUpdate(@Param("organize") Organize organize);
}
